<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<script type="text/javascript">

function loadScript(url, callback) {
    var script = document.createElement("script")
    script.type = "text/javascript";
    if(script.readyState) {//IE
        script.onreadystatechange = function() {
            if(script.readyState == "loaded" || script.readyState == "complete") {
                script.onreadystatechange = null;
                callback();
            }
        };
    } else {//其他浏览器
        script.onload = function() {
            callback();
        };
    }
    script.src = url;
    document.getElementsByTagName("head")[0].appendChild(script);
}

/*loadScript("file1.js", function(){ 
    alert("文件加载完成!");
});
*/

loadScript("file1.js", function() {
    loadScript("file2.js", function() {
        loadScript("file3.js", function() {
            alert("所有文件都已经加载!");
        });
    });
});



</script>
</head>
<body>


</body>
</html>
